{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Python The Dangerous Tool For ML & Data Science : Part 1.ipynb",
      "version": "0.3.2",
      "views": {},
      "default_view": {},
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "metadata": {
        "id": "vaLAQUhj709E",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 1.Whitespace Formatting"
      ]
    },
    {
      "metadata": {
        "id": "U1iU02qo7-zY",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for i in [1,2,3,4,5]:\n",
        "    print (i)\n",
        "    for j in [1,2,3,4,5]:\n",
        "        print (j)\n",
        "        print (i + j)\n",
        "    print (i)\n",
        "print (\"Done looping\")"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "syCZtmeV8Z5O",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "long_winded_computation =(1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "l4m2J4lx8fSC",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "list_of_lists = [[1,2,3], [4,5,6], [7,8,9]]\n",
        "easier_to_read_list_of_lists = [ [1,2,3],\n",
        "                                 [4,5,6],\n",
        "                                 [7,8,9] ]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "ArnsrrBJ8r0G",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "two_plus_three = 2 + \\\n",
        "                 3"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "qXujqYey8tCq",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for i in [1, 2, 3, 4, 5]:\n",
        "    #notice the blank line\n",
        "    print (i)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "Ms00a-vT7dAo",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 2. Python function"
      ]
    },
    {
      "metadata": {
        "id": "I8IHm_NU7dAr",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#multiply two numbers using a python function\n",
        "def multiply(x,y):\n",
        "    z = x*y\n",
        "    return z"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "RuywsnS37dA0",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "ed8c4ec3-946e-4329-bdaf-4652c12d2057",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369789014,
          "user_tz": -360,
          "elapsed": 948,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "multiply(4,3)"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "12"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 4
        }
      ]
    },
    {
      "metadata": {
        "id": "SofEZeO47dBA",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 3. Python types"
      ]
    },
    {
      "metadata": {
        "id": "9BG-D9lx7dBC",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "d1054306-dd6c-4a55-86eb-764c80868199",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369813560,
          "user_tz": -360,
          "elapsed": 876,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(' My name is Shimanto')"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "str"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 5
        }
      ]
    },
    {
      "metadata": {
        "id": "u0HQkRHV7dBL",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "0a8f542d-bbc4-4204-e2bb-595e75ac1ad7",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369825940,
          "user_tz": -360,
          "elapsed": 864,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(5)"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "int"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 6
        }
      ]
    },
    {
      "metadata": {
        "id": "Vpdy0hlr7dBW",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "734286b1-6402-4775-eff8-020c18303623",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369836184,
          "user_tz": -360,
          "elapsed": 866,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(5.0)"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "float"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 7
        }
      ]
    },
    {
      "metadata": {
        "id": "MzeGUgID7dBf",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "046abe58-a29c-45fc-ff49-4feb42322490",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369838753,
          "user_tz": -360,
          "elapsed": 846,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(None)"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "NoneType"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "metadata": {
        "id": "k2iFvlog7dBn",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "5e68c459-be8e-49c1-c2d2-df46f92072e2",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369840682,
          "user_tz": -360,
          "elapsed": 859,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(multiply)"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "function"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 9
        }
      ]
    },
    {
      "metadata": {
        "id": "qsN-JShN7dBt",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 4. Python sequences"
      ]
    },
    {
      "metadata": {
        "id": "dX76z_wN7dBx",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "##### Tuples are an immutable data structure which cannot be altered (unlike lists)"
      ]
    },
    {
      "metadata": {
        "id": "xz4omuen7dBy",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "a = (1,2,3,4)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "UAfNoMS47dB3",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "f6c01518-50a9-4339-997d-7a811aaaefd4",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369895334,
          "user_tz": -360,
          "elapsed": 4147,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(a)"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "tuple"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 11
        }
      ]
    },
    {
      "metadata": {
        "id": "G7sxToOH7dB7",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "#### Lists are mutable objects"
      ]
    },
    {
      "metadata": {
        "id": "4mqnVQXD7dB-",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "b = [1,2,3,4]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "neSds4dc7dCF",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "f0bc84c3-874f-4b63-a9f6-1c7cf9027512",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369899403,
          "user_tz": -360,
          "elapsed": 898,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(b)"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "list"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 13
        }
      ]
    },
    {
      "metadata": {
        "id": "gpyVv3HC7dCK",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "92b80e5b-ce59-417e-cfea-c20d5b642cc8",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369910132,
          "user_tz": -360,
          "elapsed": 857,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "b.append(2.5) #append to list using this function\n",
        "print(b)"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[1, 2, 3, 4, 2.5]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "cRB1mG-37dCQ",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 102
        },
        "outputId": "bc59dc4a-014d-414a-9937-23a564e1cd36",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369914143,
          "user_tz": -360,
          "elapsed": 929,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for number in b: #looping through list\n",
        "    print(number)"
      ],
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "1\n",
            "2\n",
            "3\n",
            "4\n",
            "2.5\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "jPMKdOZ67dCX",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 102
        },
        "outputId": "d4b3e62e-c920-4552-86c6-b5e1157c8692",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369918098,
          "user_tz": -360,
          "elapsed": 870,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for i in range(len(b)): #looping using index of a list\n",
        "    print(b[i])"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "1\n",
            "2\n",
            "3\n",
            "4\n",
            "2.5\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "qYVLi2Et7dCc",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "93c10b49-98bf-499d-aa18-d233512b022a",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369924626,
          "user_tz": -360,
          "elapsed": 952,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "[1,2,3] + [1,'bc','de'] #concatenate lists"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[1, 2, 3, 1, 'bc', 'de']"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 17
        }
      ]
    },
    {
      "metadata": {
        "id": "bvu48BPX7dCg",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "3c07eb67-c881-4798-892d-a6941e1a77b5",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369927474,
          "user_tz": -360,
          "elapsed": 851,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "[1,2]*3 #repeat lists"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[1, 2, 1, 2, 1, 2]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "metadata": {
        "id": "WWA05tCB7dCm",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "9c71e97f-3fee-495c-85b2-87de6bf8069c",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533369935316,
          "user_tz": -360,
          "elapsed": 1231,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "3 in b #in operator to check if required object is in list"
      ],
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "True"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 19
        }
      ]
    },
    {
      "metadata": {
        "id": "1mZXrPxd7dCq",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "#### Strings store character objects"
      ]
    },
    {
      "metadata": {
        "id": "Kc_ayN4R7dCq",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x = 'My name is Shimanto'"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "l3AxKosB7dCv",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "f950362c-7e0e-4982-ac1d-d6e8eefdbd4b",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370073247,
          "user_tz": -360,
          "elapsed": 1267,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x[0] #Access first letter"
      ],
      "execution_count": 21,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'M'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 21
        }
      ]
    },
    {
      "metadata": {
        "id": "nYZ-Z3qi7dC3",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "3b32aa27-b264-4775-f862-4ed1325a60af",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370075373,
          "user_tz": -360,
          "elapsed": 840,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x[0:1] #Still accesses only first letter"
      ],
      "execution_count": 22,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'M'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 22
        }
      ]
    },
    {
      "metadata": {
        "id": "GnDw-R5O7dC6",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "107b7f73-4499-4faf-b368-3cd31895457a",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370078251,
          "user_tz": -360,
          "elapsed": 1057,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x[0:2] #Accesses two letters"
      ],
      "execution_count": 23,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'My'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 23
        }
      ]
    },
    {
      "metadata": {
        "id": "RY0WPIMS7dC_",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "92c70ec5-7495-48d9-9606-e6cb04e6d2fe",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370082512,
          "user_tz": -360,
          "elapsed": 1078,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x[:-1] #Accesses everything except last letter"
      ],
      "execution_count": 24,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'My name is Shimant'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 24
        }
      ]
    },
    {
      "metadata": {
        "id": "6Rtw5CQ27dDF",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "b5e81f63-a9c9-47ce-a52e-0def23d16945",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370086418,
          "user_tz": -360,
          "elapsed": 1088,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x[10:] #returns all the characters from 10th position till end"
      ],
      "execution_count": 25,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "' Shimanto'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 25
        }
      ]
    },
    {
      "metadata": {
        "id": "1WTHpA677dDL",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "first = 'Harun'\n",
        "last = 'Shimanto'\n",
        "\n",
        "Name = first + ' ' + last #string concatenation"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "IxJUhb7S7dDN",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "525b251d-40e0-40d9-ac9c-edb6ef07f141",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370108448,
          "user_tz": -360,
          "elapsed": 846,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "print(Name)"
      ],
      "execution_count": 27,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Harun Shimanto\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "bGgmguzl7dDS",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "155f9bc3-7a29-4133-c9a0-cb59b9507c1c",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370114149,
          "user_tz": -360,
          "elapsed": 844,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "Name.split(' ') #split the words in a string using split function"
      ],
      "execution_count": 28,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "['Harun', 'Shimanto']"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 28
        }
      ]
    },
    {
      "metadata": {
        "id": "fmBMm2Ir7dDV",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "6482b7af-0c6c-4e07-d380-4a17a09693ab",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370117046,
          "user_tz": -360,
          "elapsed": 1072,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "Name.split(' ')[0] #Show the first word"
      ],
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Harun'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 29
        }
      ]
    },
    {
      "metadata": {
        "id": "xuIoIuVZ7dDa",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "57f9ea89-7343-422e-e868-53198a5fb91d",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370120005,
          "user_tz": -360,
          "elapsed": 822,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "Name.split(' ')[1] #Show the second word"
      ],
      "execution_count": 30,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Shimanto'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 30
        }
      ]
    },
    {
      "metadata": {
        "id": "Oocf_JP97dDe",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "11c04443-a0aa-4d54-9d81-0e23c6702f11",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370122722,
          "user_tz": -360,
          "elapsed": 899,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "Name.split(' ')[-1] #Last word from the end"
      ],
      "execution_count": 31,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Shimanto'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 31
        }
      ]
    },
    {
      "metadata": {
        "id": "FDQOmIdN7dDi",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "c455d309-ae3b-4d0f-d952-4772d8461965",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370134241,
          "user_tz": -360,
          "elapsed": 936,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#for concatenation convert objects to strings\n",
        "'Harun' + str(2)"
      ],
      "execution_count": 33,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Harun2'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 33
        }
      ]
    },
    {
      "metadata": {
        "id": "KKK05TLv7dDp",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "#### Dictionaries link keys and values"
      ]
    },
    {
      "metadata": {
        "id": "BxTP5t0y7dDq",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "c = {\"Name\" : \"Harun\", \"Height\" : 175}"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "UYoSTtrI7dDt",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "a8768dd2-e62b-4f66-e075-6744e7922c6e",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370207122,
          "user_tz": -360,
          "elapsed": 833,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "type(c)"
      ],
      "execution_count": 35,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "dict"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 35
        }
      ]
    },
    {
      "metadata": {
        "id": "VcLJu0R87dDw",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "5105542f-dc9c-4b25-c349-bcdf2ca18ba0",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370208922,
          "user_tz": -360,
          "elapsed": 930,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "print(c)"
      ],
      "execution_count": 36,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "{'Name': 'Harun', 'Height': 175}\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "Y-M7hPZj7dD0",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "158a739d-62db-42ca-8ca5-0b8167fb08e5",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370210984,
          "user_tz": -360,
          "elapsed": 847,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "c['Name'] #Access Name"
      ],
      "execution_count": 37,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Harun'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 37
        }
      ]
    },
    {
      "metadata": {
        "id": "WITaMcxN7dD5",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "1fb9b5de-09ba-4fa8-9ae5-e86a1c816e19",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370212784,
          "user_tz": -360,
          "elapsed": 846,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "c['Height']"
      ],
      "execution_count": 38,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "175"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 38
        }
      ]
    },
    {
      "metadata": {
        "id": "_ZvZIgDj7dD_",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "outputId": "052d3e21-df15-44bc-c00d-2c211bcac533",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370215170,
          "user_tz": -360,
          "elapsed": 1092,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#print all the keys\n",
        "for i in c:\n",
        "    print(i)"
      ],
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Name\n",
            "Height\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "CGWvrHaj7dEC",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "outputId": "a8ef4cfa-afca-4178-a1be-59e9d4642ae7",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370217367,
          "user_tz": -360,
          "elapsed": 1010,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#print all the values\n",
        "for i in c.values():\n",
        "    print(i)"
      ],
      "execution_count": 40,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Harun\n",
            "175\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "uwSjI8657dES",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 85
        },
        "outputId": "a977dbe7-1261-4214-efd1-84aacc7cf6aa",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370219467,
          "user_tz": -360,
          "elapsed": 866,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#iterate over all the items\n",
        "for name, height in c.items():\n",
        "    print(name)\n",
        "    print(height)"
      ],
      "execution_count": 41,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Name\n",
            "Harun\n",
            "Height\n",
            "175\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "wRe20Hz27dEZ",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "outputId": "3e65342d-1d7b-4179-f1d3-6f90dd3fa3e6",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370226657,
          "user_tz": -360,
          "elapsed": 1302,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#Unpacking a list into different variables\n",
        "a,b = ('bc','def')\n",
        "print(a)\n",
        "print(b)"
      ],
      "execution_count": 43,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "bc\n",
            "def\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "FwRXkN2g7dEc",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 5. Python dates and times"
      ]
    },
    {
      "metadata": {
        "id": "jonykaQC7dEd",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "import datetime as dt\n",
        "import time as tm"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "pza3NMlz7dEg",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "c042e75c-76fb-4c81-8261-63c361fbc43b",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370235548,
          "user_tz": -360,
          "elapsed": 874,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "tm.time() #print current time in seconds from January 1, 1970"
      ],
      "execution_count": 45,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "1533370235.0210752"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 45
        }
      ]
    },
    {
      "metadata": {
        "id": "p678As0T7dEo",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "dtnow = dt.datetime.fromtimestamp(tm.time()) #convert timestamp to datetime"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "gds2XQXh7dEq",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "e47de7be-4090-4795-be43-eb8885a9af46",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370276024,
          "user_tz": -360,
          "elapsed": 886,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "dtnow.year"
      ],
      "execution_count": 48,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "2018"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 48
        }
      ]
    },
    {
      "metadata": {
        "id": "Wnl9Ebl67dEu",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "da9954a3-6607-40d4-a8a7-38a61fb29028",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370278932,
          "user_tz": -360,
          "elapsed": 1022,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "dtnow.month"
      ],
      "execution_count": 49,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "8"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 49
        }
      ]
    },
    {
      "metadata": {
        "id": "OvfliPIE7dEx",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "delta = dt.timedelta(days=100)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "-PH7ewG47dEz",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "today = dt.date.today()"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "pEMTKCiA7dE2",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "df04571f-e4c5-4b9c-92f9-74ba2dc2ba6b",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370286940,
          "user_tz": -360,
          "elapsed": 852,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "today"
      ],
      "execution_count": 52,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "datetime.date(2018, 8, 4)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 52
        }
      ]
    },
    {
      "metadata": {
        "id": "zCXdYlTd7dE7",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "0309c9b6-154d-4f43-ef39-a919006a5631",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370311200,
          "user_tz": -360,
          "elapsed": 1018,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "today - delta #subtract 100 days from today's date"
      ],
      "execution_count": 53,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "datetime.date(2018, 4, 26)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 53
        }
      ]
    },
    {
      "metadata": {
        "id": "tAn4Fk9r7dFA",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 6. Map function"
      ]
    },
    {
      "metadata": {
        "id": "k5XVmY6q7dFA",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "a = [1,2,3,5]\n",
        "b = [8,9,10,11]\n",
        "\n",
        "c = map(min,a,b) #Find the minimum between two pairs of lists\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "8YEGZUvQ7dFC",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 85
        },
        "outputId": "d0f88b48-9a01-47a7-c239-dfa96a8b93c6",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370345868,
          "user_tz": -360,
          "elapsed": 1071,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for item in c:\n",
        "    print(item) #print the minimum of the pairs"
      ],
      "execution_count": 55,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "1\n",
            "2\n",
            "3\n",
            "5\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "dhpITWS67dFH",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 7. Lambda function"
      ]
    },
    {
      "metadata": {
        "id": "RCPqX4eL7dFK",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "function = lambda a,b,c : a+b+c #function to add three numbers"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "ssFV-ifi7dFM",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "0fe2b22c-b935-41b6-f1e3-f37b9f4bb582",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370365661,
          "user_tz": -360,
          "elapsed": 863,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "function(5,6,8) #call the function"
      ],
      "execution_count": 57,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "19"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 57
        }
      ]
    },
    {
      "metadata": {
        "id": "WZjbQ2X57dFP",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 8. Filter function"
      ]
    },
    {
      "metadata": {
        "id": "g4ZTxeIR7dFQ",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x = [0,2,3,4,5,7,8,9,10] #create a list\n",
        "x2 = filter(lambda a : a>5, x) #filter using filter function"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "7PAMtL547dFS",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "b6f7533e-3e83-4c30-ddbc-34d9c0b036d9",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370658001,
          "user_tz": -360,
          "elapsed": 531,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "print(list(x2))"
      ],
      "execution_count": 59,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[7, 8, 9, 10]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "e9j8xdf_7dFV",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 9. Reduce funtion"
      ]
    },
    {
      "metadata": {
        "id": "LufCpNxk7dFX",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "b527be04-e361-4258-c79e-42fbf42f849d",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370672615,
          "user_tz": -360,
          "elapsed": 1076,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "from functools import reduce #import reduce function\n",
        "y = [6,7,8,9,10] #create list\n",
        "reduce(lambda a,b : a*b,y) #use reduce"
      ],
      "execution_count": 60,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "30240"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 60
        }
      ]
    },
    {
      "metadata": {
        "id": "vWE96rSx7dFe",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 10. Zip function"
      ]
    },
    {
      "metadata": {
        "id": "dDegjTUO7dFj",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "9e7a5797-a923-4f38-bf10-e88598348ff2",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370683916,
          "user_tz": -360,
          "elapsed": 847,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "a = [1,2,3,4] #create two lists\n",
        "b = [5,6,7,8]\n",
        "c = zip(a,b) #Use the zip function\n",
        "print(list(c))"
      ],
      "execution_count": 61,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[(1, 5), (2, 6), (3, 7), (4, 8)]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "3JoEc88NBATY",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 11.Control Flow"
      ]
    },
    {
      "metadata": {
        "id": "3c1D7dKIBO8i",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "if (1 > 2):\n",
        "     message = \"if only 1 were greater than two…\"\n",
        "elif( 1 > 3):\n",
        "       message= \"elif stands for 'else if'\"\n",
        "else:\n",
        "    message=\"when all else fails use else (if you want to)\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "4juMRGkACDKN",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "x = 0\n",
        "while x < 10:\n",
        "   print (x, \"is less than 10\")\n",
        "   x += 1"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "bNCOnzLZC7Tl",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for x in range(10):\n",
        "    print( x, \"is less than 10\")"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "4gt24-lBDLbX",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 85
        },
        "outputId": "da290744-522c-42b4-bfac-8573cc2bcadb",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533371340920,
          "user_tz": -360,
          "elapsed": 853,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "for x in range(10):\n",
        "    if (x == 3):\n",
        "         continue # go immediately to the next iteration\n",
        "    if (x == 5):\n",
        "         break # quit the loop entirely\n",
        "    print (x)"
      ],
      "execution_count": 77,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "0\n",
            "1\n",
            "2\n",
            "4\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "HSqAuj197dFo",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "# 12. List comprehension"
      ]
    },
    {
      "metadata": {
        "id": "u-FENS6H7dFp",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#return even numbers from 1 to 50\n",
        "\n",
        "even=[]\n",
        "for i in range(50):\n",
        "    if i%2 ==0:\n",
        "        even.append(i)\n",
        "    else:\n",
        "        None\n",
        "        "
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "OO5Yejng7dFs",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "744d109a-4469-4783-8a7a-fff18b20514a",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370689219,
          "user_tz": -360,
          "elapsed": 591,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "print(even)"
      ],
      "execution_count": 63,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "Tyvo8IT_7dFu",
        "colab_type": "code",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "4a2daa73-adb7-4189-d6da-b949996cf29e",
        "executionInfo": {
          "status": "ok",
          "timestamp": 1533370693331,
          "user_tz": -360,
          "elapsed": 1041,
          "user": {
            "displayName": "Harun shimanto",
            "photoUrl": "//lh5.googleusercontent.com/-uR8PXeO98jw/AAAAAAAAAAI/AAAAAAAAA9E/M10BfXXo4OM/s50-c-k-no/photo.jpg",
            "userId": "106055380778061853749"
          }
        }
      },
      "cell_type": "code",
      "source": [
        "#Let's do the same using list comprehension\n",
        "\n",
        "even = [i for i in range(50) if i%2==0]\n",
        "print(even)"
      ],
      "execution_count": 64,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}